package entities;


import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 * Created with IntelliJ IDEA.
 * User: eagami
 * Date: 01/12/13
 * Time: 00:33
 * To change this template use File | Settings | File Templates.
 */
@Entity
@Table(name="History")
@SequenceGenerator(sequenceName="History_sequence" ,name="History_sequence")
public class History implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -2081336326466488991L;

	private Long id;
    
	private Integer locationX;
	
    private Integer locationY;

	private Date startTime;
	
    private Date lastUpdateTime;

    private Tag tag;
    
    private Objects object;

    private Station station;

 /*   public static Finder<Long,History> find = new Finder<Long,History>(
            Long.class, History.class
    );
    */
    public History(){}

	@Id
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="History_sequence")
	@Column(name = "History_id")
    public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
    
    @Column(name="Location_X",unique=false,length=20,nullable=true)	
	public Integer getLocationX() {
		return locationX;
	}

	public void setLocationX(Integer locationX) {
		this.locationX = locationX;
	}

    @Column(name="Location_Y",unique=false,length=20,nullable=true)	
	public Integer getLocationY() {
		return locationY;
	}

	public void setLocationY(Integer locationY) {
		this.locationY = locationY;
	}

	@Column(name="Start_Time",unique=false,length=20,nullable=true)
    public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

    @Column(name="Last_Update_Time",unique=false,length=20,nullable=true)
	public Date getLastUpdateTime() {
		return lastUpdateTime;
	}

	public void setLastUpdateTime(Date lastUpdateTime) {
		this.lastUpdateTime = lastUpdateTime;
	}

	@ManyToOne(fetch=FetchType.EAGER)
    @JoinColumn(name = "tag_id")
	public Tag getTag() {
		return tag;
	}

	public void setTag(Tag tag) {
		this.tag = tag;
	}

    @ManyToOne(targetEntity= Objects.class, fetch=FetchType.EAGER)
    @JoinColumn(name = "object_id")
	public Objects getObject() {
		return object;
	}

	public void setObject(Objects object) {
		this.object = object;
	}

	@ManyToOne(fetch=FetchType.EAGER)
    @JoinColumn(name = "station_id")
	public Station getStation() {
		return station;
	}

	public void setStation(Station station) {
		this.station = station;
	}

	/*@play.db.jpa.Transactional
    public static List<History> getAllHistorys(){
        return History.find.all();
    }*/
}
